package openai

import (
	"github.com/gofiber/fiber/v2"
	"zatta-gateway/config"
	"zatta-gateway/http/services"
	"zatta-gateway/pkg/db/model"
)

func ListModelsEndpoint(application *config.ApplicationConfig) func(ctx *fiber.Ctx) error {
	return func(ctx *fiber.Ctx) error {
		var models []*model.Model
		var err error
		models, err = services.ListModels(application)
		if err != nil {
			return ctx.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
				"error": err.Error(),
			})
		}
		return ctx.Status(fiber.StatusOK).JSON(models)
	}
}
